package com.example.lib_common.base

import com.example.lib_common.http.RetrofitManager
import okhttp3.OkHttpClient
import java.lang.reflect.ParameterizedType

open class BaseHttpViewModel<S>() : BaseViewModel() {
    protected val httpRepository: S by lazy {
        val type = (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0]
        @Suppress("UNCHECKED_CAST")
        RetrofitManager.create(
            type as Class<S>, getBaseUrl(), getDefaultOkHttpClient()
        )
    }


    open fun getBaseUrl(): String? {
        return null
    }

    open fun getDefaultOkHttpClient(): OkHttpClient? {
        return null
    }
}